<template>
    <div class="operationLog-container">
        <!-- 面包导航 -->
        <el-breadcrumb separator="/" style="padding-left: 10px; padding-bottom: 10px; font-size: 12px">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>日志管理</el-breadcrumb-item>
            <el-breadcrumb-item>系统日志</el-breadcrumb-item>
        </el-breadcrumb>
        <!-- 用户列表卡片区 -->
        <el-card class="box-card">
            <!--  搜索栏  -->
            <el-form :inline="true" size="mini" :model="queryMap" class="demo-form-inline">
                <el-form-item label="操作人">
                    <el-input
                        @keyup.enter.native="search"
                        clearable
                        @clear="search"
                        v-model="queryMap.username"
                        placeholder="操作人"
                    ></el-input>
                </el-form-item>
                <el-form-item label="ip地址">
                    <el-input
                        @keyup.enter.native="search"
                        clearable
                        @clear="search"
                        v-model="queryMap.ip"
                        placeholder="ip地址"
                    ></el-input>
                </el-form-item>

                <el-form-item label="操作位置">
                    <el-input
                        @keyup.enter.native="search"
                        clearable
                        @clear="search"
                        v-model="queryMap.location"
                        placeholder="操作位置"
                    ></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="search" icon="el-icon-search">查询</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button
                        type="danger"
                        @click="deleteFileOrDirectory(sels)"
                        :disabled="this.sels.length === 0"
                        class="el-icon-delete"
                        >批量删除</el-button
                    >
                </el-form-item>
            </el-form>

            <!-- 表格区域 -->
            <template>
                <el-table
                    border
                    stripe
                    size="mini"
                    :data="LogData"
                    style="width: 100%"
                    height="460"
                    @selection-change="selsChange"
                >
                    <el-table-column type="selection" width="55" align="center"></el-table-column>
                    <el-table-column prop="operation" label="操作" width="150"></el-table-column>
                    <el-table-column :show-overflow-tooltip="true" prop="method" label="方法" width="180">
                    </el-table-column>
                    <el-table-column :show-overflow-tooltip="true" prop="params" label="参数" width="100">
                        <template slot-scope="scope">
                            <span>{{ scope.row.params }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="time" label="耗时" width="120" sortable>
                        <template slot-scope="scope">
                            <el-tag v-if="scope.row.time >= 2000" size="mini" type="danger">
                                {{ scope.row.time + "毫秒" }}
                            </el-tag>
                            <el-tag size="mini" v-else-if="scope.row.time >= 1000 && scope.row.time <= 2000">
                                {{ scope.row.time + "毫秒" }}
                            </el-tag>
                            <el-tag v-else type="success" size="mini">
                                {{ scope.row.time + "毫秒" }}
                            </el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column prop="location" label="操作地点" width="240"></el-table-column>
                    <el-table-column prop="ip" label="IP地址" width="160"></el-table-column>
                    <el-table-column prop="userBrowser" label="浏览器"></el-table-column>
                    <el-table-column prop="username" label="操作人" width="150"></el-table-column>
                    <el-table-column prop="createTime" label="时间" sortable width="180"></el-table-column>

                    <el-table-column label="操作" width="100px;" fixed="right">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                size="mini"
                                v-hasPermission="'log:delete'"
                                icon="el-icon-delete"
                                @click="del(scope.row.id)"
                                >删除</el-button
                            >
                        </template>
                    </el-table-column>
                </el-table>
            </template>

            <!-- 分页 -->
            <el-pagination
                style="margin: 10px 0; float: right"
                background
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="this.queryMap.pageNum"
                :page-sizes="[10, 15, 20]"
                :page-size="this.queryMap.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
            ></el-pagination>
        </el-card>
    </div>
</template>

<script>
export default {
    name: "Operationlog",

    data() {
        return {
            sels: [], //选中的值显示
            LogData: [],
            total: 0, //总共多少条数据
            queryMap: { pageNum: 1, pageSize: 10, location: "" }, //查询对象
        };
    },

    mounted() {},

    methods: {
        getLogList() {},
        // 查询
        search() {},

        // 批量删除
        deleteFileOrDirectory(sels) {},

        // 获取多选的项
        selsChange(sels) {
            this.sels = sels;
        },

        del(id) {},

        //改变页码
        handleSizeChange(newSize) {
            this.queryMap.pageSize = newSize;
            this.getLogList();
        },
        //翻页
        handleCurrentChange(current) {
            this.queryMap.pageNum = current;
            this.getLogList();
        },
    },
};
</script>

<style lang="sass" scoped></style>
